package io;

import io.sage.modules.hcnet.service.HcNetRadioService;
import io.sage.modules.socket.service.impl.SocketClientWeatherServiceImpl;
import io.sage.modules.socket.service.impl.SocketClientServiceImpl;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.annotation.Resource;

@SpringBootApplication
@EnableScheduling
@MapperScan(basePackages = {"io.sage.modules.*.dao"})
public class AdminApplication extends SpringBootServletInitializer implements CommandLineRunner {

	@Resource
	private HcNetRadioService hcNetRadioService;

	@Resource
	private SocketClientServiceImpl socketClientService;
	
	@Resource
	private SocketClientWeatherServiceImpl socketClient1Service;

	public static void main(String[] args) {
		SpringApplication.run(AdminApplication.class, args);
	}

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(AdminApplication.class);
	}

	@Override
	public void run(String... strings) throws Exception {
		socketClientService.start();
		socketClient1Service.start();
		hcNetRadioService.initAllPlay();
	}
}
